#include<iostream>
#include<vector>
#include<unistd.h>
using namespace std;
size_t num = 10;
int main()
{
  vector<pid_t> allchild;
  for(int i = 0;i < num;i++)
  {
    pid_t id = fork();
    if(id == 0)
    {
      while(true)
      {
        cout<<"I am Sub Process, pid: "<<getpid()<<", ppid: "<<getppid()<<endl;
        sleep(5);
      }
    }
      allchild.push_back(id);
  }

  cout<<"我的孩子是: ";
    for(auto e : allchild)
    {
      cout<<e<<" ";
    }
    while(true)
    {
      cout<<"我是父进程, pid: "<<getpid()<<", ppid: "<<getppid()<<endl;
      sleep(1);
    }
  return 0;
}
